import { MockMethod } from 'vite-plugin-mock'
import Mock, { Random } from 'mockjs'

let AllList = Mock.mock({
  'list|132': [
    {
      'id|+1': 1,
      name: '@cname',
      'sex|0-1': 1,
      'age|18-60': 30,
      birthday: '@date',
      email: '@email',
      address: '@county(true)',
      content: '@cword(50)',
    },
  ],
})

export default [
    {
      url: '/api/{{ moduleName }}/list',
      method: 'get',
      response: ({ query }) => {
        return {
          code: 0,
          data: {
            list: AllList,
          },
        }
      },
    },

    {
        url: '/api/{{ moduleName }}/detail',
        method: 'get',
        response: option => {
            let info = AllList.filter(item => item.id == option.id)
            return {
                code: 0,
                data: info
            }
        }
    },
    {
        url: '/api/{{ moduleName }}/create',
        method: 'post',
        response: {
            code: 0,
            data: {
                isSuccess: true
            }
        }
    },
    {
        url: '/api/{{ moduleName }}/edit',
        method: 'post',
        response: {
            code: 0,
            data: {
                isSuccess: true
            }
        }
    },
    {
        url: '/api/{{ moduleName }}/delete',
        method: 'delete',
        response: {
            code: 0,
            data: {
                isSuccess: true
            }
        }
    }
] as MockMethod[]
